package Main;

import java.io.File;
import java.io.FileReader;
import java.io.PushbackReader;

import junit.framework.TestCase;
import minijava.lexer.Lexer;
import minijava.node.Start;
import minijava.parser.Parser;

public class TestBench extends TestCase {
	public void testSmall1() {
		File testFolder = new File("testes/small/1");
		File[] testFiles = testFolder.listFiles();

		for (File testFile : testFiles) {
			if (testFile.isFile()) {
				System.out.print("Teste " + testFile + ": ");
				try {
					Lexer lexer = new Lexer(new PushbackReader(new FileReader(
							testFile), 1024));
					Parser parser = new Parser(lexer);
					Start ast = parser.parse();
					System.out.println("OK");
				} catch (Exception e) {
					System.out.println(e);
				}
			}
		}
	}
	
	public void testSmall2() {
		File testFolder = new File("testes/small/2");
		File[] testFiles = testFolder.listFiles();

		for (File testFile : testFiles) {
			if (testFile.isFile()) {
				System.out.print("Teste " + testFile + ": ");
				try {
					Lexer lexer = new Lexer(new PushbackReader(new FileReader(
							testFile), 1024));
					Parser parser = new Parser(lexer);
					Start ast = parser.parse();
					System.out.println("OK");
				} catch (Exception e) {
					System.out.println(e);
				}
			}
		}
	}
	
	public void testSmall3() {
		File testFolder = new File("testes/small/3");
		File[] testFiles = testFolder.listFiles();

		for (File testFile : testFiles) {
			if (testFile.isFile()) {
				System.out.print("Teste " + testFile + ": ");
				try {
					Lexer lexer = new Lexer(new PushbackReader(new FileReader(
							testFile), 1024));
					Parser parser = new Parser(lexer);
					Start ast = parser.parse();
					System.out.println("OK");
				} catch (Exception e) {
					System.out.println(e);
				}
			}
		}
	}
	
	public void testSmall4() {
		File testFolder = new File("testes/small/4");
		File[] testFiles = testFolder.listFiles();

		for (File testFile : testFiles) {
			if (testFile.isFile()) {
				System.out.print("Teste " + testFile + ": ");
				try {
					Lexer lexer = new Lexer(new PushbackReader(new FileReader(
							testFile), 1024));
					Parser parser = new Parser(lexer);
					Start ast = parser.parse();
					System.out.println("OK");
				} catch (Exception e) {
					System.out.println(e);
				}
			}
		}
	}
	
	public void testLarge() {
		File testFolder = new File("testes/large");
		File[] testFiles = testFolder.listFiles();

		for (File testFile : testFiles) {
			if (testFile.isFile()) {
				System.out.print("Teste " + testFile + ": ");
				try {
					Lexer lexer = new Lexer(new PushbackReader(new FileReader(
							testFile), 1024));
					Parser parser = new Parser(lexer);
					Start ast = parser.parse();
					System.out.println("OK");
				} catch (Exception e) {
					System.out.println(e);
				}
			}
		}
	}
	
}
